package com.edevp.common.mybatis.dto;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author Lean
 * @description 分页信息
 * @create 2019-11-11 10:24
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageDTO<T> implements Serializable {
	private Long totalCount;
	private List<T> rows;
	private Long pageCount;
	private Integer pageSize;

	public Integer getPageCount(){
		if(this.totalCount != null && this.pageSize != null){
			long pageCountL = (this.totalCount+this.pageSize-1)/this.pageSize;
			return Integer.parseInt(String.valueOf(pageCountL));
		}
		return null;
	}

}